import 'package:flutter/material.dart';
// import 'package:fluwx/fluwx.dart';
import 'package:get/get.dart';
import 'package:xin_he/utils/xh_styles.dart';

import '../../../routes/xin_he_routes.dart';
import 'xin_he_adopt_num_select_logic.dart';

class XinHeAdoptNumSelectPage extends StatelessWidget {
  XinHeAdoptNumSelectPage({Key? key, required this.count}) : super(key: key);
  final int count;
  final logic = Get.put(XinHeAdoptNumSelectLogic());
  final state = Get.find<XinHeAdoptNumSelectLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Obx(() => Container(
      padding: const EdgeInsets.symmetric(horizontal: 15),
      decoration: const BoxDecoration(color: Colors.white,borderRadius: BorderRadius.only(topLeft: Radius.circular(10),topRight: Radius.circular(10))),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Container(
            height: 50,
            alignment: Alignment.centerLeft,
            child: Row(children: [
              Text('已认养棵树',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500),),
              Spacer(),
              Text('${count}',style: TextStyle(color: XinHeColor('#888888'),fontSize: 13,fontWeight: FontWeight.w500),),

            ],),
          ),

          Container(
            height: 50,
            alignment: Alignment.centerLeft,
            child: Row(children: [
              Text('请选择认养数量',style: TextStyle(color: XinHeColor('#333333'),fontSize: 13,fontWeight: FontWeight.w500),),
              Spacer(),
              GestureDetector(
                onTap: (){
                  logic.handleCount(false);

                },
                child: Container(height: 23,width: 23,color: XinHeColor('#EDEDED'),
                  alignment: Alignment.center,
                  child: Text('-',style: TextStyle(color: XinHeColor('#555555'),fontSize: 15,fontWeight: FontWeight.w500),),
                ),
              ),
              const SizedBox(width: 2,),
              Container(height: 23,width: 38,color: XinHeColor('#EDEDED'),
                alignment: Alignment.center,
                child: Text('${state.count.value}',style: TextStyle(color: XinHeColor('#333333'),fontSize: 15,fontWeight: FontWeight.w500),),
              ),
              const SizedBox(width: 2,),
              GestureDetector(
                onTap: (){
                  logic.handleCount(true);

                },
                child: Container(height: 23,width: 23,color: XinHeColor('#EDEDED'),
                  alignment: Alignment.center,
                  child: Text('+',style: TextStyle(color: XinHeColor('#555555'),fontSize: 15,fontWeight: FontWeight.w500),),
                ),
              ),

            ],),
          ),
          const SizedBox(height: 23,),

          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 63-15),
            child: Row(children: [
              GestureDetector(
                onTap:(){
                  Get.back();
                },
                child: Container(
                  height: 31,
                  width: Get.width*0.5-63-5,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(color: XinHeColor('#EDEDED'),borderRadius: BorderRadius.circular(15.5)),
                  child: Text('取消',style: TextStyle(color: XinHeColor('#555555'),fontSize: 13,fontWeight: FontWeight.w500),),
                ),
              ),
              Spacer(),

              GestureDetector(
                onTap: (){
                  // Fluwx fluwx = Fluwx();
                  // fluwx.open(target: MiniProgram(username: 'gh_af9e3be1a447'));



                  // Fluwx fluwx = Fluwx();
                  // fluwx.open(target: MiniProgram(username: 'gh_af9e3be1a447'));
                   logic.requestAdoptSure();


                  // logic.textAlipay();
                },
                child: Container(
                  height: 31,
                  width: Get.width*0.5-63-5,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(gradient: LinearGradient(colors: [XinHeColor('#F89A30'),XinHeColor('#E84128')]),borderRadius: BorderRadius.circular(15.5)),
                  child: const Text('确定',style: TextStyle(color: Colors.white,fontSize: 13,fontWeight: FontWeight.w500),),
                ),
              ),

            ],),
          ),

          SizedBox(height: 36+Get.mediaQuery.padding.bottom,)



        ],),
    ));
  }
}
